{% extends 'WebQuant/base.html' %}
{% block title %}学院{% endblock %}
{% block content %}
<div class="wrap">
    <div class="main" style="overflow:hidden; min-height:810px">
      <div id="les1">
            <div class="wrap_head">
                <div class="head_left" >
                    <ul>
                        <li class="on college" id="stock"><a href="">新手入门</a></li>
                    </ul>
                </div>

            </div>

            <div class="college_cont" id="lesson1"></div></div>
            <div id="les2"><div class="wrap_head">
                <div class="head_left">
                    <ul>
                        <li class="on college" id="stock"><a href="">Python学习</a></li>
                    </ul>
                </div>

            </div>
            <div class="college_cont" id="lesson2"></div></div>
             <div id="les3"><div class="wrap_head">
                <div class="head_left">
                    <ul>
                        <li class="on college" id="stock"><a href="">策略研究</a></li>
                    </ul>
                </div>
             </div>
            <div class="college_cont" id="lesson3"></div></div>
    </div>
</div><!-- 内容 -->
<script src="/static/WebQuant/js/jq.js"></script>
<script src="/static/WebQuant/js/csrf.js"></script>
<script src="/static/WebQuant/js/base.js"></script>
<script>
var isLog = {{log}}
if (isLog)
{
    $(".l_case2").css("display","block");
    $(".l_case1").css("display","none");
}
else
{
    $(".l_case2").css("display","none");
    $(".l_case1").css("display","block");
}
function numdb(num){
  if (num<10) {
    return '0'+num
  }else
    return num;
}
$.ajax({
      dataType: 'jsonp',
      url: 'http://192.168.6.229:3000/api/classList',
      jsonpCallback:"classList",
      success: function(jsons) {
        //var jsons = JSON.parse(str);
        var i=0,j=0,k=0;
        var data=jsons.rows;
        for(var x in data){
            switch(data[x].node)
            {
            case '1':
              i++;
              $("#les1").show();
              $("#lesson1").append('<a class="lesson" href="'+data[x].url+'" target="_blank"><span>'+numdb(i)+'</span><h3>第'+i+'课</h3><p>'+data[x].title+'</p></a>');
              break;
            case '2':
              j++;
              $("#les2").show();
              $("#lesson2").append('<a class="lesson" href="'+data[x].url+'" target="_blank"><span>'+numdb(j)+'</span><h3>第'+j+'课</h3><p>'+data[x].title+'</p></a>');
              break;
            default:
              k++;
              $("#les3").show();
              $("#lesson3").append('<a class="lesson" href="'+data[x].url+'" target="_blank"><span>'+numdb(k)+'</span><h3>第'+k+'课</h3><p>'+data[x].title+'</p></a>');
            }
        }
      },
      error: function(err) {
        alert('error');
        alert(err);
      }
});
</script>
{% endblock %}